package com.google.code.opencode.service.impl;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.scheduling.quartz.QuartzJobBean;

import com.google.code.opencode.service.TwitterUpdater;

public class TwitterUpdaterJob extends QuartzJobBean {

	private static Log log = LogFactory.getLog(TwitterUpdaterJob.class);
	private TwitterUpdater twitterUpdater;
	private int timeout;

	@Override
	protected void executeInternal(JobExecutionContext context)
			throws JobExecutionException {
		log.info("Starting the job");
		twitterUpdater.sendUpdate();
		log.info("Finished the job");
	}

	@Required
	public void setTwitterUpdater(TwitterUpdater twitterUpdater) {
		this.twitterUpdater = twitterUpdater;
	}

	@Required
	public void setTimeout(int timeout) {
		this.timeout = timeout;
	}

	public int getTimeout() {
		return timeout;
	}

}
